cluster.name: {{ es_cluster_name }}
node.name: {{ inventory_hostname }}
node.master: true
node.data: true
node.ingest: true
path.data: {{ es_datadir }}
path.logs: {{ es_basedir }}/logs
network.host: {{ ansible_host }}
http.port: {{ es_http_port }}
transport.tcp.port: {{ es_transport_port }}
action.destructive_requires_name: true

bootstrap.memory_lock: true
bootstrap.system_call_filter: false

# 安全设置
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: {{ es_basedir }}/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: {{ es_basedir }}/config/certs/elastic-certificates.p12

# 开启跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

#任务多时导致任务拒绝，加大队列大小，可以在间歇性任务量陡增的情况下，缓存任务在队列，等高峰过去逐步消费完
thread_pool.write.queue_size: 10000
#线程数
thread_pool.write.size: {{ ansible_processor_vcpus }}

cluster.max_shards_per_node: 10000

http.max_initial_line_length: 128k
http.max_header_size: 64kb
http.max_content_length: 500mb

node.attr.box_type: hot
node.max_local_storage_nodes: 256

{% if es_mode == 'single' %}
discovery.type: single-node
{% endif %}

{% if es_mode == 'cluster' %}
# 仅在第一次启动集群时需要，后续重启必须注释掉
{% if es_initial_start | default(true) and master | default(false) %}
cluster.initial_master_nodes: [{% for host in groups['elasticsearch'] if hostvars[host].master | default(false) %}"{{ hostvars[host].inventory_hostname }}"{% if not loop.last %},{% endif %}{% endfor %}]
{% endif %}
{% endif %}

{% if es_mode == 'cluster' %}
{# 集群发现配置 #}
discovery.zen.ping.unicast.hosts: [{% for host in groups['elasticsearch'] %}"{{ hostvars[host].ansible_host }}:{{ es_transport_port | default(9300) }}"{% if not loop.last %},{% endif %}{% endfor %}]
{% endif %}
